package communicationMessages;

import serverComuncation.Observer;
import database.DB;

public class NumOfConnectionMessage extends Message {

	@Override
	public String getAnswer() {
		
		String []arr = this.content.split(delimiter);
		String ans ="numOfConnection" + delimiter;
		String wrongFormat = "wrong format" + delimiter;
		if (arr.length != 1)
		{
			ans += wrongFormat;
		}
		else
		{
			String userName = arr[0];
			if (!DB.isAdmin(userName))
			{
				ans+=wrongFormat;
			}
			else
			{
				String userRoll = "admin" + delimiter;
				ans+=userRoll + Observer.getNumOfConnection() + delimiter;
			}
		}
		
		
		return ans;
	}

}
